<?php
$dsn='mysql:dbname=db_books;host=127.0.0.1';
try {
    $pdo=new PDO($dsn,'db_books','db_books');
}catch (Exception $e){
    echo '连接错误'.$e->getMessage();
}